package com.example.nongye.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;

import androidx.appcompat.app.AppCompatActivity;

import com.example.nongye.R;
import com.example.nongye.databinding.ActivityAccountBinding;
import com.jaeger.library.StatusBarUtil;
import com.tencent.mmkv.MMKV;

public class AccountActivity extends AppCompatActivity {

    private ActivityAccountBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityAccountBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        StatusBarUtil.setColor(this, getResources().getColor(R.color.white), 0);
        StatusBarUtil.setLightMode(this);

        binding.btnBack.setOnClickListener(view -> finish());

        binding.tvDetail.setOnClickListener(view -> {
            Intent intent = new Intent(AccountActivity.this, BillActivity.class);
            startActivity(intent);
        });

        initView();
    }

    private void initView() {
        String card = MMKV.defaultMMKV().getString("card", "");
        if (!TextUtils.isEmpty(card) && card.length() > 5) {
            binding.tvCardNo.setText(card.substring(0, 4) + " **** " + card.substring(card.length() - 4));
        }
        String yue = MMKV.defaultMMKV().getString("yue", "");
        binding.tvYue.setText(yue);
    }


}